# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=criu
pkgver=3.14
pkgrel=1
pkgdesc="Process tree checkpoint/restore utility"
url="https://criu.org"
arch="x86_64"
license="GPL-2.0-or-later LGPL-2.1-only"
makedepends="xmlto asciidoc python3 protobuf-c-dev libnet-dev libnl3-dev
	protobuf-dev libcap-dev"
checkdepends="py3-yaml"
options="!check" # https://github.com/checkpoint-restore/criu/issues/434
subpackages="$pkgname-dev $pkgname-doc py3-$pkgname:_py:noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/checkpoint-restore/criu/archive/v$pkgver.tar.gz"

build() {
	# https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed
	export LDFLAGS=$(echo $LDFLAGS |sed 's|-Wl,--as-needed||') PYTHON=python3
	make
}

check() {
	make test
}

package() {
	make PREFIX=/usr DESTDIR="$pkgdir" LIBDIR=/usr/lib install
	rm "$pkgdir"/usr/libexec/criu/scripts/systemd-autofs-restart.sh
	rm -f "$pkgdir"/usr/lib/*.a
}

_py() {
	replaces="py-$pkgname" # Backwards compatibility
	provides="py-$pkgname=$pkgver-r$pkgrel" # Backwarwds compatibility

	pkgdesc="Python3 bindings for Criu"
	depends="python3 py3-protobuf"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/
}

sha512sums="4ef716cebcfa5db77122bfc53875b229cd4734567a940b22f1b5eac988aa240b953d1a87412ca55044e82ed6fe5b3f70b0830344a62bdf673090031634db806f  criu-3.14.tar.gz"
